import Vue from "vue";
import VueRouter from "vue-router";
import HomeView from "../views/HomeView.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/home/index",
  },
  {
    path: "/home",
    name: "home",
    component: HomeView,
    children: [
      {
        path: "/home/index",
        name: "/home/index",
        component: () => import("../views/Index.vue"),
      },
      {
        path: "/home/user", //用户管理
        name: "/home/user",
        component: () => import("@/views/module/user/SysUser.vue"),
      },
      {
        path: "/home/owner", //业主管理
        name: "/home/owner",
        component: () => import("@/views/module/user/OwnerInfo.vue"),
      },
      {
        path: "/home/house-info", //查询房屋
        name: "/home/house-info",
        component: () => import("@/views/module/house/HouseInfo.vue"),
      },
      {
        path: "/home/house-add", //新增房屋
        name: "/home/house-add",
        component: () => import("@/views/module/house/HouseAdd.vue"),
      },
      {
        path: "/home/charging-add", //新增收费
        name: "/home/charging-add",
        component: () => import("@/views/module/charging/ChargingAdd.vue"),
      },
      {
        path: "/home/charging-info", //查询收费
        name: "/home/charging-info",
        component: () => import("@/views/module/charging/ChargingInfo.vue"),
      },
      {
        path: "/home/device-info", //查询设备
        name: "/home/device-info",
        component: () => import("@/views/module/device/DeviceInfo.vue"),
      },
      {
        path: "/home/device-add", //新增设备
        name: "/home/device-add",
        component: () => import("@/views/module/device/DeviceAdd.vue"),
      },
      {
        path: "/home/device-repair-add", //新增维修设备
        name: "/home/device-repair-add",
        component: () => import("@/views/module/device/DeviceRepairAdd.vue"),
      },
      {
        path: "/home/device-repair", //维修设备查询
        name: "/home/device-repair",
        component: () => import("@/views/module/device/DeviceRepair.vue"),
      },
      {
        path: "/home/complaint", //投诉管理
        name: "/home/complaint",
        component: () => import("@/views/module/complaint/Complaint.vue"),
      },
      {
        path: "/home/myset", //管理员设置
        name: "/home/myset",
        component: () => import("@/views/module/myset/MySet.vue"),
      },
    ],
  },
  {
    path: "/about",
    name: "about",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
